package main;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

//A simple canvas to briefly inform the user of what the application can do.
public class HelpCanvas extends Canvas implements CommandListener
{
    private Display display;
    Command backCommand;
    
    public HelpCanvas(Display d)
    {
        display=d;
        backCommand=new Command("Back",Command.BACK,0);
        this.addCommand(backCommand);
        this.setCommandListener(this);
    }
    
    protected void paint(Graphics g)
    {
        try
        {
            g.drawImage(Image.createImage("/images/back.png"), 0, 0, Graphics.TOP | Graphics.LEFT);
        }
        catch (Exception ex){}
        
        g.setColor(255,255,255);
        
        int textHeight=0;
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD|Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
        g.drawString("TAP", getWidth()/2, 0,  Graphics.TOP|Graphics.HCENTER);
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
        g.drawString("a currency to select it as", getWidth()/2, textHeight+=19,  Graphics.TOP|Graphics.HCENTER);
        g.drawString("the base currency", getWidth()/2, textHeight+=14,  Graphics.TOP|Graphics.HCENTER);
        
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD|Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
        g.drawString("LONG PRESS", getWidth()/2, textHeight+=18,  Graphics.TOP|Graphics.HCENTER);
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
        g.drawString("to access more infos and actions", getWidth()/2, textHeight+=19,  Graphics.TOP|Graphics.HCENTER);
        g.drawString("of the pressed currency", getWidth()/2, textHeight+=14,  Graphics.TOP|Graphics.HCENTER);
        
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD|Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
        g.drawString("SWIPE", getWidth()/2, textHeight+=18,  Graphics.TOP|Graphics.HCENTER);
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
        g.drawString("a currency (drag it fast) to", getWidth()/2, textHeight+=19,  Graphics.TOP|Graphics.HCENTER);
        g.drawString("replace it with another", getWidth()/2, textHeight+=14,  Graphics.TOP|Graphics.HCENTER);
        
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD|Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
        g.drawString("TYPE", getWidth()/2, textHeight+=25,  Graphics.TOP|Graphics.HCENTER);
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
        g.drawString("with your numpad to set a", getWidth()/2, textHeight+=19,  Graphics.TOP|Graphics.HCENTER);
        g.drawString("specific value", getWidth()/2, textHeight+=14,  Graphics.TOP|Graphics.HCENTER);
        g.drawString("(key '*' works as backspace)", getWidth()/2, textHeight+=12,  Graphics.TOP|Graphics.HCENTER);
    }

    public void commandAction(Command c, Displayable d)
    {
        if (c==backCommand)
        {
            display.setCurrent(mainMIDlet.canvas);
        }
    }
    
}